<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="net.ojbk.saishi.service.*" import="net.ojbk.util.*" import="net.ojbk.saishi.util.StringTool" import="net.ojbk.saishi.po.*"%>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>参赛赛事页面</title>

	<link href="css/bootstrap-jf.css" rel="stylesheet">
	<link href="css/datepicker3-jf.css" rel="stylesheet">
	<link href="css/styles-jf.css" rel="stylesheet">

</head>

<%
boolean isLogin = false;
String[] basicInfoName = new String[0];
String[] basicInfo = new String[0];
String[] extraInfoName = new String[0];
String userId = "null";
String matchId = "";
String formatFileName = "null";
syMatch match = null;
// TODO 判断是否显示 文件上传部分
if ((session != null && session.getAttribute("login") != null && (boolean)session.getAttribute("login"))) { // 如果未登录
	isLogin = true;
	userId = (String)session.getAttribute("myId");
	matchId = request.getParameter("matchId");
	if ("".equals(matchId) || matchId == null)
		matchId = "OYLAQZ";

	basicInfoName = ContestantService.getBasicInfoName(matchId);
	for (String temp:basicInfoName) {
		System.out.printf(temp);
	}
	basicInfo = ContestantService.getBasicInfo(userId, matchId);
	extraInfoName = ContestantService.getExtraInfoName(matchId);
	match = MatchBackService.getMatch(matchId);
	formatFileName = StringTool.formatFileName(match.getFileFormat(), basicInfoName, basicInfo, new String[0], new String[0]);
}
%>

<body>
	
	<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
		<div class="container-fluid">
			<div class="navbar-header">
				<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#sidebar-collapse">
					<span class="sr-only">Toggle navigation</span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
				</button>
				<a class="navbar-brand" href="home.jsp"><span>师易</span>赛事服务平台</a>
				<ul class="user-menu">
					<li class="dropdown pull-right">
						<a href="home.jsp" class="dropdown-toggle" data-toggle="dropdown">个人主页</a>
					</li>
				</ul>
			</div>
			
		</div><!-- /.container-fluid -->
	</nav>
	
	<div id="sidebar-collapse" class="col-sm-3 col-lg-2 sidebar">
		<form role="search">
			<div class="form-group">
				<input type="text" class="form-control" placeholder="欢迎来到师易赛事服务平台">
			</div>
		</form>
		<ul class="nav menu">
			<li><a href="all.jsp"><span class="glyphicon glyphicon-stats"></span> 全部赛事</a></li> 
			<li role="presentation" class="divider">主办方</li>  
			<li><a href="launch.jsp"><span class="glyphicon glyphicon-list-alt"></span>发布赛事</a></li>
			<li><a href="havaLaunch.jsp"><span class="glyphicon glyphicon-dashboard"></span>已发布赛事</a></li>
			<li><a href="Statistics.jsp"><span class="glyphicon glyphicon-th"></span> 赛事情况统计</a></li>
			<li><a href="backstage.jsp"><span class="glyphicon glyphicon-th"></span> 赛事后台</a></li>
			<li role="presentation" class="divider">参赛方</li>  
			<li class="active"><a href="part.jsp"><span class="glyphicon glyphicon-user"></span> 参赛赛事</a></li>
			<li><a href="havaPart.jsp"><span class="glyphicon glyphicon-user"></span> 已赛赛事</a></li>
		</ul>
		<div class="attribution">赛事服务 by <a href="">师易</a>
		</div>
	</div><!--/.sidebar-->
	<div class="col-sm-9 col-sm-offset-3 col-lg-10 col-lg-offset-2 main">			
		<div class="row">
			<ol class="breadcrumb">
				<li><a href="home.jsp"><span class="glyphicon glyphicon-home"></span></a></li>
				<li class="active">Part</li>
			</ol>
		</div><!--/.row-->
		
		<div class="row">
			<div class="col-lg-12">
			<%
			if (isLogin) {
			%>
				<h1 class="page-header">参加赛事(<%= matchId %>)</h1>
			<% } else { %>
				<h1 class="page-header">参加赛事(未登录)</h1>
			<% } %>
			</div>
		</div><!--/.row-->
			
		<div class="row">
			<div class="col-lg-12">
				<div class="panel panel-default">
					<div class="panel-heading">师易赛事 - 参加赛事</div>
					<div class="panel-body">
						<div class="">
							<form role="form" action="PartMatchServlet" method="post" enctype="multipart/form-data">
								<input type="hidden" name="matchId" value="<%= matchId %>">
								<div class="form-group" >
									<fieldset style="border:1px solid black;padding:5px 5px 10px;wrid">
										<label>需要获取的基本信息</label>
										<hr >
										<div class="form-row">
										<%
											for (int i=0; i<basicInfoName.length; i++) {
										%>
											<div class="field-label">
												<label for="field1"><%= basicInfoName[i] %></label>
												：<%= basicInfo[i] %>
											</div>
										<% } %>
										</div>
									</fieldset>   
								</div>
								<div class="form-group" >
									<fieldset style="border:1px solid black;padding:5px 5px 10px;wrid">
										<label>额外需要的信息</label>
										<hr >
										<%
										// extraInfoName
										for (String extraName : extraInfoName) {
										%>
										<div class="form-row">
											<div class="field-label"><label for="field1"><%= extraName %></label>：</div>
											<div class="field-widget"><input name="<%= extraName %>" id="field1" class="form-control" title="Enter your <%= extraName %>" /></div>
										</div>
										<% } %>
									</fieldset>   
								</div>
								<%
								if (match.getNeedFile()) {
								%>
								<div class="form-group" >
									<fieldset style="border:1px solid black;padding:5px 5px 10px;wrid">
										<label>需要上交的文件</label>
										<hr >

										<div class="form-row">
											<div class="field-label"><label for="field3">You'r file</label>：<%= formatFileName %></div>
											<div class="field-widget"><input type="file" name="file"></div>
										</div>    
									</fieldset>   
								</div>
								<% }  %>
								<%
								if (isLogin) {
								%>
								<div  style="position: absolute; bottom: -70px; left: 40px;">

									<button type="submit" class="btn btn-primary">Submit Button</button>
									<button type="reset" class="btn btn-default">Reset Button</button>
								</div>
								<% } %>
							</form>

						</div>
					</div>
				</div><!-- /.col-->
			</div><!-- /.row -->

		</div>
	</div>
	<script src="js/jquery-1.11.1.min-jf.js"></script>
	<script src="js/bootstrap.min.js"></script>
	<script src="js/chart.min.js"></script>
	<script src="js/chart-data.js"></script>
	<script src="js/easypiechart.js"></script>
	<script src="js/easypiechart-data.js"></script>
	<script src="js/bootstrap-datepicker.js"></script>
	<script>
		!function ($) {
			$(document).on("click","ul.nav li.parent > a > span.icon", function(){		  
				$(this).find('em:first').toggleClass("glyphicon-minus");	  
			}); 
			$(".sidebar span.icon").find('em:first').addClass("glyphicon-plus");
		}(window.jQuery);

		$(window).on('resize', function () {
			if ($(window).width() > 768) $('#sidebar-collapse').collapse('show')
		})
		$(window).on('resize', function () {
			if ($(window).width() <= 767) $('#sidebar-collapse').collapse('hide')
		})
</script>	
</body>

</html>

